//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import gridBody from "../../views/Camp/Schedule/SignCode.vue";
let shuju = {
  campsiteId: "",
  phase_id_fk: "",
  Qiantui: 2
};
let extension = {
  components: {
    //动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: "", //{ template: "<div>扩展组xx件</div>" },
    gridBody: gridBody,
    gridFooter: "",
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: "",
    // modelBody: modelBody,
    modelFooter: ""
  },
  buttons: {
    view: [
      {
        name: "签退码",
        icon: "md-add-circle",
        class: "",
        value: "QDMBUTTON",
        type: "success",
        onClick: function(row) {
          console.log(this);
          this.$refs.gridBody.open2(shuju);
        }
      }
    ],
    box: [],
    detail: []
  }, //扩展的按钮
  data() {
    return {
      // 营地
      // 营期
    };
  },
  methods: {
    //事件扩展
    getSearchFormOption(field) {
      let option;
      this.searchFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },

    onInit() {
      //   this.columns.push({
      //     title: '操作',
      //     fixed: 'right',
      //     width: 200,
      //     render: (h, { row, column, index }) => {
      //         return h(
      //             "div", { style: {} }, [
      //               h(
      //                 "a", {
      //                     props: {},
      //                     style: {},
      //                     on: {
      //                         click: (e) => {
      //                           this.$refs.gridBody.openWindowOne(row);
      //                         }
      //                     }
      //                 },
      //                 "查看"
      //             ),
      //                 h(
      //                     "a", {
      //                         props: {},
      //                         style: {},
      //                         on: {
      //                             click: (e) => {
      //                               this.$refs.gridBody.openWindowOne(row);
      //                             }
      //                         }
      //                     },
      //                     "编辑行程"
      //                 ),
      //             ])
      //     }
      // })
      this.$store.getters.data().viewPageTest = this;
      let campsiteId = this.getSearchFormOption("campsiteId");
      let phase_id_fk = this.getSearchFormOption("phase_id_fk");
      campsiteId.onChange = val => {
        let VSales = Number(val);
        this.$nextTick(() => {
          let parmas = {
            order: "desc",
            page: 1,
            rows: 100,
            sort: "phase_id_fk",
            wheres: `[{"name":"campsite_id_fk","value":"${VSales}","displayType":"text"}]`
          };
          this.http.post("/api/V_campphase/getPageData", parmas).then(res => {
            let a = res.rows.map(i => {
              return {
                key: i.phase_id_fk,
                value: i.phase_name
              };
            });
            this.$set(phase_id_fk, "data", a);
          });
        });
        phase_id_fk.onChange = val => {
          // console.log(val,"phase_id_fk")
          shuju.phase_id_fk = val;
        };
        shuju.campsiteId = VSales;
      };
    },

    searchBefore(param) {
      //查询ViewGird表数据前,param查询参数
      //添加其他查询条件,也可以在后台扩展中写查询条件
      // console.log(param, 'param')
      let wheres = {
        name: "type",
        value: "2",
        displayType: "text"
      };
      param.wheres.push(wheres);
      return true;
    },
    rowClick({ row, column, event }) {
      //查询界面table点击行选中当前行
      //console.log(row,column,event);
      this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    }
  }
};
export default extension;
